
###APPENDIX C
#rating
mm_rating <- cj(df, rating ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                  Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~potSD)
#Plot
cj_rating<-plot(mm_rating,group = "potSD", vline = 0.5, size=5) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(3.69, 4.31)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Potential SD")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 


#Rating classes
mm_class_rating <- cj(df1, rating ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                        Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~oesch)

#Plot
cj_rating_class<-plot(mm_class_rating,group = "oesch", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(3.8, 4.6)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Class")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 

cj_rating_class$data <- cj_rating_class$data[c(100:114, 133:147, 199:213,115:132, 148:165, 214:231),]


#mm for educ_groups
mm_class_rating <- cj(df1, rating ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                        Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~educ_2)

#Plot
cj_rating_educ<-plot(mm_class_rating,group = "educ_2", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(3.9, 4.5)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Educational Groups")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 


